<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<!-- header begin -->
<head>
    <title>共享办公 | 注册</title>
    <jsp:include page="../includes/header.jsp"/>

</head>
<!-- header end -->
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="#"><b>共享办公</b></a>
    </div>
    <!-- /.login-logo -->
    <div class="login-box-body">
        <p class="login-box-msg">注册账号</p>

        <form action="/register" method="post">
            <c:if test="${message != null}">
                <div class="alert alert-danger alert-dismissible">
                    <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
                    <i class="icon fa fa-warning"></i> ${message}
                </div>
            </c:if>
            <div class="form-group has-feedback">
                <input type="text" name="username" class="form-control" value="${username}" placeholder="用户名">
                <span class="glyphicon glyphicon-user form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input id="email" name="email" value="${email}" type="email" class="form-control" placeholder="邮箱">
                <span class="glyphicon glyphicon-envelope form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input style="display: inline-block;width: 70%" name="code" value="${code}" class="form-control" placeholder="邮箱验证码">
                <button id="getCode"  style="display: inline-block;width: 28%" class="btn btn-info btn-flat" data-toggle="modal" data-target="#modal-danger" >获取验证码</button>
            </div>
            <div class="form-group has-feedback">
                <input name="password" value="${password}" type="password" class="form-control" placeholder="密码">
                <span class="glyphicon glyphicon-lock form-control-feedback"></span>
            </div>
            <div class="form-group has-feedback">
                <input style="display: inline-block;width: 70%" name="vrifyCode" class="form-control" placeholder="验证码">
                <img style="-webkit-user-select: none;display: inline-block;width: 28%" src="getCoder" alt="验证码">
            </div>
            <div class="row">
                <!-- /.col -->
                <div class="col-xs-offset-8 col-xs-4">
                    <button type="submit" class="btn btn-primary btn-block btn-flat">注册</button>
                </div>
                <!-- /.col -->
            </div>
        </form>
    </div>

</div>
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
<!-- jQuery 3 -->
<script src="../../static/bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap 3.3.7 -->
<script src="../../static/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- iCheck -->
<script src="../../static/plugins/iCheck/icheck.min.js"></script>
<script>
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass: 'iradio_square-blue',
            increaseArea: '20%' /* optional */
        });        
    });
    function changeCode(){

    }
    // 点击获取验证码操作
    // 点击获取验证码操作
    $("#getCode").click(function (e) {
        e.preventDefault();
        let count = 60;
        let res = $("#email").val();
        if (res ==="" || res==null){
            alert("请先填邮箱")
        }else {
            $.ajax({
                url:"/getCode",
                type:"get",
                data:{"email":res},
                contentType:"application/json;charset=UTF-8",
                dataType:"json",
                success:function (res) {
                    if (res === 0){
                        alert("请输入正确格式邮箱")
                    }
                }
            });
            const countDown = setInterval(function () {
                if (count === 0) {
                    $("#getCode").text('重新发送').removeAttr('disabled');
                    clearInterval(countDown);
                } else {
                    $("#getCode").attr('disabled', true);
                    $("#getCode").text(count + '秒后再试');
                }
                count--;
            },1000)
        }


    })

</script>
</body>
</html>
